<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head th:replace="common/layout :: common_header(~{::title},~{::link})">
    <title>账号管理</title>
</head>
<body>
<div class="main-container">
    <div class="main-content-inner">
        <div class="page-content">
            <input type="hidden" id="ycclientid" name="ycclientid" th:value="${sysClient.id}">
            <div class="row">
                <div class="col-xs-12">
                    <form action="" class="form-inline" id="clientAccountForm">
                        <label>账号：</label><input
                            type="text" name="clientnickaccount">
                        <button class="btn btn-primary btn-rounded btn-outline btn-sm "
                                type="button"	onclick="search()">
                            <i class="fa fa-search"></i> 查询
                        </button>
                        <button class="btn btn-primary btn-rounded btn-outline btn-sm "
                                type="reset">
                            <i class="fa fa-refresh"></i> 重置
                        </button>
                    </form>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="pull-left">
                        <button class="btn btn-primary btn-sm" data-toggle="tooltip"
                                data-placement="left" onclick="add()" title="添加">
                            <i class="fa fa-plus"></i> 添加
                        </button>
                    </div>
                    <div class="pull-right"></div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <table id="clientAccounttable"  data-toggle="table" data-side-pagination="server"
                           data-striped="true"  data-query-params="queryParams" data-pagination-loop="false"
                           data-page-number="1" data-data-field="list" data-total-field="totalRow"
                           data-content-type="application/x-www-form-urlencoded" data-click-to-select="true"
                           data-pagination="true" data-method="post"  th:data-url="@{/sys/client/queryAccount/}+${sysClient.id}">
                        <thead>
                        <tr>
                            <th class="center" data-checkbox="true"> </th>
                            <th   data-field="id" width="10%"> id</th>
                            <th   data-field="clientnickaccount" width="20%"> 客户软件账号</th>
                            <th   data-field="clientnickname" width="20%"> 客户账号昵称</th>
                            <th   data-field="clientnick" width="20%"> 客户使用软件</th>
                            <th   data-field="id" data-formatter="optFormatter" width="30%">操作</th>
                        </tr>
                        </thead>
                    </table>f
                </div>
            </div>
            <!-- /.col -->
        </div>

    </div>
    <!-- end main container -->
</div>

<div th:replace="common/commonJS"></div>
<script>
    function queryParams(params){
        var temp = $("#clientAccountForm").serializeJSON();
        temp.pageSize=params.limit;   //页面大小
        temp.pageNumber=(params.offset / params.limit) + 1;   //页码
        temp.sort=params.sort;      //排序列名
        temp.sortOrder=	 params.order; //排位命令（desc，asc）
        return temp;
    }


    function optFormatter(value,row,index){
        return "<div class='hidden-sm hidden-xs btn-group'>"+
                "<button class='btn btn-xs btn-info' onclick='editaccount("+value+")'>修改账号信息</button>"
                +"<button class='btn btn-xs btn-info' onclick='del("+value+")'>删除账号信息</button>"
                +"</div>"
    }

    function add(){
        var id = document.getElementById('ycclientid').value;
        jp.openWindow("新增"+'账号信息',"sys/client/addAccount/"+id,"1000px", "550px");
    }

    function getIdSelections() {
        return $.map($("#clientAccounttable").bootstrapTable('getSelections'), function (row) {
            return row.id
        });
    }

    function editaccount(id){
        jp.openWindow("客户"+'账号信息修改',ctx+"sys/client/editAccount/"+id,"1000px", "550px");
    }

    function search(){
        $('#clientAccounttable').bootstrapTable('refresh');
    }
    function del(id){
        jp.confirm('确定要删除选择的客户吗？', function (){
                    jp.loading();
                    $.get(ctx+"sys/client/deleteAccount?id=" +id, function(data){
                        if(data){
                            $('#clientAccounttable').bootstrapTable('refresh');
                            jp.success("删除成功");
                        }else{
                            jp.error("删除失败");
                        }
                    })

                }

        );
    }

</script>
</body>
</html>
